package com.oasystem.utils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URISyntaxException;
import java.util.Map;
import java.util.Properties;

public class BackupConfigUtil {
	private static Properties prop;

	static {
		prop = new Properties();
		InputStream in = BackupConfigUtil.class.getResourceAsStream(
				"/backupconfig.properties");
		try {
			prop.load(in);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static String getParam(String key) {
		return prop.getProperty(key);
	}

	public static void store(Map<String, String> params) throws IOException,
			URISyntaxException {
		for (String key : params.keySet()) {
			String value = params.get(key);
			prop.put(key, value);
		}

		OutputStream fos = new FileOutputStream(new File(BackupConfigUtil.class
				.getResource("/backupconfig.properties").toURI()));
		prop.store(fos, "123");
	}

}
